package com.antunnel.basicorm.widget.pagination;


import java.util.List;

public class Page
{
  private int pageNum;
  private int pageSize = 10;
  private long totalCount;
  private List results;
  private Long offset = null;

  public Page()
  {
  }

  public Page(int pageNum, int pageSize)
  {
    this.pageNum = pageNum;
    this.pageSize = pageSize;
  }

  public Page(int pageNum, int pageSize, long totalCount, List results)
  {
    this.pageNum = pageNum;
    this.pageSize = pageSize;
    this.totalCount = totalCount;
    this.results = results;
  }

  public Page(Integer pageNum) {
    this.pageNum = pageNum.intValue();
  }

  public boolean isHasFirst()
  {
    return getPageNum() > 1;
  }

  public boolean isHasLast()
  {
    return getPageNum() < getTotalPageCount();
  }

  public boolean isHasNext()
  {
    return this.pageNum < getTotalPageCount();
  }

  public boolean isHasPrevious()
  {
    return this.pageNum > 1;
  }

  public int getTotalPageCount()
  {
    Long maxPage = Long.valueOf(0L);
    maxPage = Long.valueOf(getTotalCount() / getPageSize());
    Long localLong1;
    if (getTotalCount() % getPageSize() != 0L) {
      localLong1 = maxPage; Long localLong2 = maxPage = Long.valueOf(maxPage.longValue() + 1L);
    }return maxPage.intValue();
  }

  public int getPageNum()
  {
    return this.pageNum;
  }

  public void setPageNum(int pageNum)
  {
    this.pageNum = pageNum;
  }

  public int getPageSize()
  {
    return this.pageSize;
  }

  public void setPageSize(int pageSize)
  {
    this.pageSize = pageSize;
  }

  public long getTotalCount()
  {
    return this.totalCount;
  }

  public void setTotalCount(Long totalCount)
  {
    this.totalCount = totalCount.longValue();
  }

  public List getResults()
  {
    return this.results;
  }

  public void setResults(List results)
  {
    this.results = results;
  }

  public Long getOffset() {
    return this.offset;
  }

  public void setOffset(Long offset) {
    this.offset = offset;
  }
}